var t = getApp();

Page({
    data: {
        Height: 0,
        LastHeight: 0,
        rotation: [],
        activity_list: [],
        advert_one: {},
        advert_two: {},
        advert_three: {},
        advert_four: {},
        name: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        is_rotation: !1
    },
    onLoad: function(t) {
        this.getData();
    },
    imgHeight: function(t) {
        var a = wx.getSystemInfoSync().windowWidth * t.detail.height / t.detail.width + "px";
        parseInt(a) > this.data.LastHeight && (this.setData({
            Height: a
        }), this.data.LastHeight = parseInt(a));
    },
    getData: function() {
        var a = this;
        this.data.isLoadMore = !1;
        var i = t.getNetAddresss("plugin.commission-activity.api.index.index");
        t._postNetWork({
            url: i,
            showToastIn: !1,
            data: {
                page: this.data.page
            },
            success: function(t) {
                var i = t.data;
                if (1 == i.result) {
                    var e = i.data.activity;
                    if (a.setData({
                        rotation: i.data.rotation,
                        activity_list: e.data,
                        page: e.current_page,
                        total_page: e.last_pag,
                        is_rotation: !(!i.data.is_rotation || 1 != i.data.is_rotation)
                    }), i.data.adv) {
                        var o = i.data.adv;
                        a.setData({
                            advert_one: o.mini_advert_one,
                            advert_two: o.mini_advert_two,
                            advert_three: o.mini_advert_three,
                            advert_four: o.mini_advert_four
                        });
                    }
                    i.data.name && wx.setNavigationBarTitle({
                        title: i.data.name
                    });
                } else wx.showToast({
                    icon: "none",
                    title: i.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    gotoDiy: function(t) {
        var a = t.currentTarget.dataset.url;
        if (a) try {
            wx.navigateTo({
                url: a
            });
        } catch (t) {
            wx.showToast({
                title: "链接设置错误:" + a,
                icon: "none",
                duration: 2e3
            });
        } else wx.showToast({
            title: "链接未设置",
            icon: "none",
            duration: 2e3
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    gotoDetail: function(t) {
        var a = t.currentTarget.dataset.index, i = this.data.activity_list[a].id;
        wx.navigateTo({
            url: "/packageB/member/distribution_queue/DistributionActivityDetail/DistributionActivityDetail?id=" + i
        });
    },
    tosearch: function() {
        wx.navigateTo({
            url: "/packageB/member/distribution_queue/DistributionSearch/DistributionSearch"
        });
    },
    onUnload: function() {},
    onPullDownRefresh: function() {},
    _getMoreData: function() {
        var a = this, i = {
            page: this.data.page
        }, e = "";
        a.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        e = t.getNetAddresss("plugin.commission-activity.api.index.index"), t._postNetWork({
            url: e,
            showToastIn: !1,
            data: i,
            success: function(t) {
                var i = t.data;
                1 == i.result ? a.setData({
                    isLoadMore: !0,
                    activity_list: a.data.activity_list.concat(i.data.activity.data)
                }) : a.setData({
                    page: a.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        }));
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});